Skip to content

bpo-46209: add documentation for decoding newlines in the io module#30308

Open
guoci wants to merge 4 commits intopython:mainfrom
guoci:doc_newline_decoders
Open

bpo-46209: add documentation for decoding newlines in the io module#30308
guoci wants to merge 4 commits intopython:mainfrom
guoci:doc_newline_decoders

Conversation

@guoci
Copy link
Contributor

@guoci guoci commented Dec 30, 2021

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Dec 30, 2021
.. attribute:: newlines

a tuple of types of newlines encountered, or the newline if only
one type of newline is found.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The types are not clear here. Are you saying this is a tuple of strings or one string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type is either a string or tuple of strings

cpython/Lib/_pyio.py

Lines 1971 to 1980 in e18d815

def newlines(self):
return (None,
"\n",
"\r",
("\r", "\n"),
"\r\n",
("\n", "\r\n"),
("\r", "\r\n"),
("\r", "\n", "\r\n")
)[self.seennl]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok! I wouldn’t say types of newlines, unless that phrase is used elsewhere in the docs, it could be confusing.

Copy link
Contributor Author

@guoci guoci Dec 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about changing to representations of newlines?

records the types of newlines encountered. When used with

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds a bit abstract to me. These are newlines, meaning strings.
Isn’t there an existing phrase in io docs or dosctrings that can be reused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find any in the io docs, The docstring of that class says types of newlines.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth just giving some examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listed all the possible values.

@guoci
Copy link
Contributor Author

guoci commented Jan 1, 2022

@merwok Also, may I request you to look at #30276 too? It is very related to this.

Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs complied on my machine. Looks ok.

@guoci guoci force-pushed the doc_newline_decoders branch from 0081b76 to 2c73105 Compare October 31, 2025 15:01
@guoci
Copy link
Contributor Author

guoci commented Nov 14, 2025

@merwok is that ok now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting change review docs Documentation in the Doc dir

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

8 participants